<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/struts/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="./style/alternative.css" media="all" rel="stylesheet" />
<style type="text/css">
#itemList {
border: 2px broove #eee;
margin-top: 1em;
line-height:1.8em;
width:95%
}
#itemList th{
text-align:center
}
#itemList td{
border: 1px solid #eee;
}
#itemAction {
padding-left: 0.3em;
word-spacing:normal;
text-align:left;
}
#itemAction input {
background-color:#389;
color:#eec;
font-family: Arial;
}
#taskAction {
padding-top: 0.5em;
padding-left: 0.5em;
text-align:left;
}
</style>
<script type='text/javascript' src='script/prototype.js'></script>
<script type='text/javascript' src='script/common.js'></script>

<SCRIPT LANGUAGE="JavaScript">
var checkedAll = false;

function onDelete(){
	 var s = $$('#table input');
	 var trs = $$('#table tr');
	 for(var i=s.length-1; i>=0; i--)
	 {
	  if (s[i].checked)
	   trs[i].remove();
	 }

}
function checkForm(){
	var checked = "";
    $$('input[type="checkbox"][name="itemID"]').select(function(i){return i.checked}).each(function(i)
    {
       //alert(i.value)
       checked = checked + i.value;
	});  
    if(checked=="") {
        alert("请选择一个事务");
        return false;
    }
    return true;
	
} 


function submitForm(imethod, itype) {
	var ret = true;
	//alert("imethod=" + imethod + ", itype=" + itype);
	if(imethod!="add") {
	    ret = checkForm();
	    if(!ret) {
		    return false;
		}
	} else {
		$("itemType").value = itype;
	}
	if(imethod == 'delete') {
	    var ret = confirm("你确信删除这些记录吗?");
	    if(!ret) {
	        return;
		}
	} else if(imethod == 'asTask') {
		$("taskType").value = itype;
		//alert("taskType=" + $F("taskType"));
	} else if(imethod == 'asItem') {
		$("itemType").value = itype;
		//alert("itemType=" + $F("itemType"));
	}
	$("method").value=imethod;
	$("itemsForm").submit();
	
}
</SCRIPT>
</head>
<body>
<div id="content"><div id="content_inner">
<center>
<h2>
<c:choose>
<c:when test="${param.itemType==1}">
也许会做的事
</c:when>
<c:when test="${param.itemType==2}">
仅作参考
</c:when>
<c:when test="${param.itemType==3}">
健康清单
</c:when>
<c:when test="${param.itemType==4}">
生日清单
</c:when>
<c:when test="${param.itemType==5}">
维修清单
</c:when>
<c:when test="${param.itemType==6}">
假日清单
</c:when>
<c:when test="${param.itemType==7}">
清洁清单
</c:when>
<c:when test="${param.itemType==8}">
幸福感清单
</c:when>
<c:when test="${param.itemType==9}">
已完成事务
</c:when>
<c:otherwise>
待办事项
</c:otherwise>
</c:choose>
</h2>
</center>

<form name="itemsForm" id="itemsForm" method="post" action="item.htm">
<display:table htmlId="itemList" name="itemList" sort="list" 
     class="its" id="item" requestURI="item.htm">
<display:setProperty name="basic.empty.showtable" value="true" />
<display:setProperty name="basic.msg.empty_list_row" value="<tr class='empty'><td colspan='{0}'>没有记录</td></tr>"/>
<display:column title="<INPUT TYPE=\"checkbox\" name=\"checkAllBox\" id=\"checkAllBox\" onclick=\"checkAll('checkAllBox')\">" sortable="true" headerClass="sortable">
<INPUT TYPE="checkbox" NAME="itemID" ID="itemID" value="${item.itemID}" >
</display:column>
<display:column title="事务" sortable="true" headerClass="sortable">
<a href="item.htm?itemType=${param.itemType}&method=edit&itemID=${item.itemID}">${item.itemName}</a>
</display:column>
<display:column property="description" title="细节" sortable="true" headerClass="sortable"/>
<display:column title="类别" sortable="true" headerClass="sortable" style="width:3em">
${categories[item.categoryID].description}
</display:column>
<display:column title="创建时间" sortable="true" headerClass="sortable" style="width:6em">
<fmt:formatDate value="${item.createTime}" pattern="MM/dd/yy HH:mm:ss"/>
</display:column>
<display:column title="<input type='button' onclick=\"submitForm('add',0)\" value='添加事务'/>" class="taskOperation" style="white-space:nowrap">
<a href="item.htm?method=finish&itemID=${item.itemID}&itemType=${param.itemType}" class="icon_btn pic_right" title="完成"><span>完成</span></a>
<a href="item.htm?method=edit&itemID=${item.itemID}&itemType=${param.itemType}" class="icon_btn pic_edit" title="编辑"><span>编辑</span></a>
<a href="item.htm?method=delete&itemID=${item.itemID}&itemType=${param.itemType}" class="icon_btn pic_delete" title="删除"><span>删除</span></a>
</display:column>
</display:table>
<div id="itemAction">
<input type="hidden" name="method" id="method">
<input type="hidden" name="itemType" id="itemType" value="${param.itemType}">
<input type="hidden" name="taskType" id="taskType">
<c:if test="${0 eq param.itemType or empty param.itemType}">
<div id="taskAction"> <strong>作为</strong>&nbsp; 
<input type="button" name="action" onclick="submitForm('delete',0)" value="垃圾"/>
<input type="button" name="action" onclick="submitForm('asTask',1)" value="下一步行动"/>
<input type="button" name="action" onclick="submitForm('asTask',2)" value="我的任务"/>
<input type="button" name="action" onclick="submitForm('asTask',3)" value="委派他人"/>
<input type="button" name="action" onclick="submitForm('asItem',1)"  value="备忘事项"/>
<input type="button" name="action" onclick="submitForm('asItem',2)"  value="参考事项"/>
</div>
</c:if>
</div>
</form>
</div><!-- content_inner -->
</div><!-- content -->
</body>
</html>